//
//  LoginEventListener.m
//  PokerPlus
//
//  Created by sunrui-MacBook on 11-7-28.
//  Copyright 2011 139.ME. All rights reserved.
//

#import "LoginEventListener.h"
#import "SocketEngine.h"
#import "AppDelegate.h"


@implementation LoginEventListener

- (void)OnConncet: (SocketEngine *) socket
{
	[super OnConncet:socket];
	[[AppDelegate sharedDelegate] cmdGetUserInfo:socket];
}

- (void)OnDisconncet: (SocketEngine *) socket
{
	[super OnDisconncet:socket];
}

- (void)OnRecv: (SocketEngine *) socket cmdId: (int) cmdId msgLen: (size_t) msgLen
{
	[super OnRecv:socket cmdId:cmdId msgLen:msgLen];
	
	if (cmdId == hhcLoginSuccess) {
		if (msgLen < sizeof(UsrInfo)) {
			return;
		}
		
		[[AppDelegate sharedDelegate] rsSetUserInfo:socket];
		[[AppDelegate sharedDelegate] cmdGetRoomSort:socket];
		NSLog(@"加载用户信息");
		return;
	}
		
	if (cmdId == hhcSortedRoom) {
		
		[[AppDelegate sharedDelegate] rsSetRoomSort:socket];
		
		NSLog(@"加载房间种类");
		return;
	}
	
	if (cmdId == hhcRoomList) {
		[[AppDelegate sharedDelegate] rsSetRoomList:socket];
		NSLog(@"加载房间列表成功");
		return;
	}
	
	if (cmdId == hhcRoomInfo) {
		[[AppDelegate sharedDelegate] rsSetRoomInfo:socket];
		NSLog(@"加载房间用户信息成功");
		return;
	}
	
	if (cmdId == hhcEnterRoomSuccess) {
		[[AppDelegate sharedDelegate] rsEnterRoom:socket withResult:YES];
		NSLog(@"进入房间成功");
		return;
	}
	if (cmdId == hhcReflashGameInfo) {
		[[AppDelegate sharedDelegate] rsRefreshGameInfo:socket];
	}
}

- (void)dealloc{
	[super dealloc];
}
@end
